initSelect()
function initSelect() {
    let els = document.querySelectorAll('.gd-select:not(.gd-init-select)')
    const blurEvent = document.createEvent('Event');
    blurEvent.initEvent('blur', true, true);
    els.forEach(item => {
        item.setAttribute('tabindex', 0)
        item.setAttribute('role', 'select')
        let str  = ''
        if(!item.innerHTML) {
            str += '<div class="gd-select-title">' +
                '<div class="label"></div>' +
                '<i class="iconfont icondown1"></i>' +
                '</div>' +
                '<div class="gd-select-wrap"></div>'
            item.innerHTML = str
        }
        const wrap = item.querySelector('.gd-select-wrap')
        const icon = item.querySelector('.gd-select-title .iconfont')
        item.addEventListener('focus', e => {
            wrap.show()
            if(icon){
                icon.classList.add('is-reverse')
            }
        })
        const options = wrap.querySelectorAll('li')
        if(options.length > 0 && !wrap.querySelector('.is-active')) {
            options[0].classList.add('is-active')
        }
        const label = item.querySelector('.gd-select-title .label')
        options.forEach(option => {
            option.setAttribute('role', 'option')
            if(option.classList.contains('is-active')) {
                option.setAttribute('aria-selected', true)
            } else {
                option.setAttribute('aria-selected', false)
            }
            option.addEventListener('click', e => {
                if(!e.target.classList.contains('is-active')) {
                    label.innerText = e.target.innerText
                    const lastedActive = e.target.parentElement.querySelector('.is-active')
                    lastedActive.classList.remove('is-active')
                    lastedActive.setAttribute('aria-selected', false)
                    e.target.classList.add('is-active')
                    e.target.setAttribute('aria-selected', true)

                    item.blur()
                }
            })
        })

        item.addEventListener('blur', e => {
            wrap.hide()
            if(icon) {
                icon.classList.remove('is-reverse')
            }
            // this.blurEvent(e)
        })
    })
}
